home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (C) 2002 Tom Parker (tom@carrott.org),
- Matthias Münch (matthias@amigaworld.de)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- In addition, as a special exception, Tom Parker and Matthias Münch give
- permission to link the code of this program with a TCP stack of your
- choice, any official MUI libraries or classes and any custom MUI classes
- that should be necessary for the operation of this program. This
- exception also gives you permission to distribute linked combinations
- including this software with any of the before-mentioned libraries and
- classes. You must obey the GNU General Public License in all respects for
- all of the code used other than that provided by the before-mentioned
- libraries and classes. As part of this exception you are obliged to
- follow the license terms of the before-mentioned libraries, this license
- does not compel you to follow those terms, but if you do not then you may
- not link with those libraries. If you modify this file, you may extend
- this exception to your version of the file, but you are not obligated to
- do so. If you do not wish to do so, delete this exception statement from
- your version.
- */
- /*
- ** user notifications
- */
-
- #include "common.h"
-
- #include <proto/exec.h>
- #include <proto/datatypes.h>
- #include <proto/dtclass.h>
- #include <clib/datatypes_protos.h>
- #include <clib/alib_protos.h>
- #include <datatypes/datatypes.h>
- #include <datatypes/datatypesclass.h>
- #include <datatypes/soundclass.h>
-
- #include "madthread.h"
-
- THREAD_DECL(sound_player);
-
-
- void sound_play(char *fname)
- {
- if(!fname || *fname == '\0') return;
- mt_run(&sound_player, fname, NULL);
- }
-
-
- THREAD(sound_player)
- {
- mthread *t;
- struct Library *DataTypesBase;
- Object *sample;
- struct dtTrigger trigger;
- long sig;
-
- t = mt_start();
- if(!t) return;
-
- DataTypesBase = OpenLibrary("datatypes.library", 39);
- if(!DataTypesBase) {
- mt_end(t);
- return;
- }
-
- sig = AllocSignal(-1);
- if(sig == -1) {
- CloseLibrary(DataTypesBase);
- mt_end(t);
- return;
- }
-
- sample = NewDTObject((char*)t->data, DTA_GroupID, GID_SOUND, TAG_DONE);
- if(!sample) {
- FreeSignal(sig);
- CloseLibrary(DataTypesBase);
- mt_end(t);
- return;
- }
-
- SetDTAttrs(sample, NULL, NULL,
- SDTA_SignalBit, (1L << sig),
- SDTA_SignalTask, (ULONG) t->task,
- TAG_DONE);
-
- trigger.MethodID = DTM_TRIGGER;
- trigger.dtt_GInfo = NULL;
- trigger.dtt_Function = STM_PLAY;
- trigger.dtt_Data = NULL;
- DoDTMethodA(sample, 0L, 0L, (Msg)&trigger);
-
- Wait((1L<<sig) | SIGBREAKF_CTRL_C);
-
- DisposeDTObject(sample);
- FreeSignal(sig);
- CloseLibrary(DataTypesBase);
- mt_end(t);
- }
-